var QRCodeInputMethod = IBImgInputMethod.extend({
	size: 3,
	menu_node: null,
	size_map: null,
	constructor: function()
	{
		var x = this;
		var menu_handler = function(pos) { x.size = x.size_map[pos]; return true; }

		this.menu_node = new GFMenuNode($GFS('Select output size'));
		this.menu_node.SetItem(0,$GFS('Small'),menu_handler);
		this.menu_node.SetItem(1,$GFS('Medium'),menu_handler);
		this.menu_node.SetItem(2,$GFS('Large'),menu_handler);
		this.menu_node.SetItem(3,$GFS('Extra Large'),menu_handler);

		this.size_map = new Array(2,3,4,6);
	},
	IMName: function()
	{
		return 'QRCode';
	},
	GetLanguage: function()
	{
		return 'util';
	},
	GetMenuNode: function()
	{
		return this.menu_node;
	},
	SuggestionType: function()
	{
		return null;
	},
	isKeyValid: function(key,m)
	{
		if(m != 0 && m != Const.KEY_SHIFT) return false;

		if((97 <= key && key <= 122) || (65 <= key && key <= 90) || (48 <= key && key <= 58)) return true;
		else return false;
	},
	onInternalBufferStart: function(iwin)
	{
		iwin.SetCompleteKeyCode(13,0);
		// remap shift+enter to enter...
		iwin.SetMapKey(13,Const.KEY_SHIFT,function(_this) { _this.AppendBuffer("\n"); });
		iwin.SetInstruction($GFS('Press Enter to complete'));
		return false;
	},
	onActive: function()
	{
		this.ime.SetPreeditText($GFS('You can press Esc Esc 6 to configure this input method'));
	},
	GetImageUrl: function(buf)
	{
		return 'http://qrcode.kaywa.com/img.php?s='+this.size+'&d=' + encodeURI(buf);
	},
	GetHTMLPostfix: function()
	{
		return '<br />&nbsp;';
	},
	SelectHandler: function(obj,pos)
	{
		this.size = this.list_size[pos];
		this.ime.StartInternalBuffer(obj);
	}
});
